<?php
$user = "user";
$pass = "pass";
$dbname = "mercatino";
try {
    $db = new PDO('mysql:host=localhost;dbname='.$dbname, $user, $pass);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $rs = $db->query('SELECT count(*) from regione');
    print_r($rs->fetchColumn());
    $rs = $db->query('SELECT * from regione');
    foreach($rs as $row) {
        print_r($row);
    }
    $db = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}
?>
